/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2008-2013 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
#ifndef OSGEARTH_DRIVER_TFS_FEATURE_SOURCE_OPTIONS
#define OSGEARTH_DRIVER_TFS_FEATURE_SOURCE_OPTIONS 1

#include <VBF_3DMap/VBF_Terrain/Common.h>
#include <VBF_3DMap/VBF_Terrain/URI.h>
#include <VBF_3DMap/VBF_Features/VBF_SourceFeature.h>

namespace osgEarth { namespace Drivers
{
    using namespace osgEarth;
    using namespace osgEarth::Features;

    /**
     * Options for the TFS feature driver.
     */
    class TFSFeatureOptions : public CVBF_OptionsDriverSourceFeature // NO EXPORT; header only
    {
    public:
        /** Base URL of the TFS service */
        CVBF_Optional<URI>& url() { return _url; }
        const CVBF_Optional<URI>& url() const { return _url; }
                
        /** Data format extension of TFS data (json, gml) */
        CVBF_Optional<std::string>& format() { return _format; }
        const CVBF_Optional<std::string>& format() const { return _format; }        

    public:
        TFSFeatureOptions( const CVBF_Options& opt =CVBF_Options() ) : CVBF_OptionsDriverSourceFeature( opt ) {
            setDriver( "tfs" );
            fromConfig( m_conf );
        }

        virtual ~TFSFeatureOptions() { }

    public:
        CVBF_Config getConfig() const {
            CVBF_Config conf = CVBF_OptionsDriverSourceFeature::getConfig();
            conf.updateIfSet( "url", _url ); 
            conf.updateIfSet( "format", _format );            
            return conf;
        }

    protected:
        void mergeConfig( const CVBF_Config& conf ) {
            CVBF_OptionsDriverSourceFeature::mergeConfig( conf );
            fromConfig( conf );
        }

    private:
        void fromConfig( const CVBF_Config& conf ) {
            conf.getIfSet( "url", _url );
            conf.getIfSet( "format", _format );
        }

        CVBF_Optional<URI>         _url;        
        CVBF_Optional<std::string> _format;
    };

} } // namespace osgEarth::Drivers

#endif // OSGEARTH_DRIVER_TFS_FEATURE_SOURCE_OPTIONS

